﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Collections.ObjectModel;

namespace Hardanger.Features.ServerFuzzer.ServerFuzzerEngine
{
    public class RepeatingStringFuzzerEngine : IServerFuzzerEngine
    {
        #region Fields

        private string _fuzzString;
        private long _currentLength;

        #endregion //Fields

        #region Properties

        public bool Configurable
        {
            get { return true; }
        }

        public string Description
        {
            get { return "Blasts the server with massive strings"; }
        }

        public string Name
        {
            get { return "Repeating String Fuzzer"; }
        }

        public string FuzzString { get; set; }
        public long MinLength { get; set; }
        public long MaxLength { get; set; }
        public long CurrentLength
        {
            get
            {
                if (_currentLength < MinLength)
                    _currentLength = MinLength;
                return _currentLength;
            }
            private set
            {
                _currentLength = value;
            }
        }
        public bool IsDone
        {
            get
            {
                return MaxLength <= CurrentLength;
            }
        }

        #endregion //Properties

        #region Public Functions

        public string GetNextValue(FuzzerSettingType type)
        {
            if (IsDone)
                return "";

            var sb = new StringBuilder();
            for (long i = 0; i < CurrentLength; i++)
                sb.Append(FuzzString);

            CurrentLength++;
            return sb.ToString();
        }

        #endregion //Public Functions

        #region Private Functions


        #endregion //Private Functions


        
    }
}
